<?php
/**
 * Created by PhpStorm.
 * User: dell1
 * Date: 2016/11/20
 * Time: 10:12
 */
header('Content-Type;text/htm;charset=utf-8');
session_start();
if(isset($_GET['action']) && $_GET['action']=='logout'){

    //清除COOKIE数据
    setcookie('username','',time()-1);
    setcookie('password','',time()-1);

    //清除SESSION数据
    unset($_SESSION['userinfo']);

    //如果SESSION中没有其他数据，则销毁SESSION
    if(empty($_SESSION)){
        session_destroy();
    }

    //跳转到登录页面
    header('Location: login.php');

    //终止脚本
    die;
}
if(isset($_SESSION['userinfo'])){
    $login=true;
    $userinfo=$_SESSION['userinfo'];
}else{
    $login=false;
}
define('APP','itcast');
require 'user_html.php';